#杀死进程

import multiprocessing
import time

def foo():
    print('starting process!')
    for i in range(10):
        print('--->%d\n'%i)
        time.sleep(1)
    print('Finished function')

if __name__=='__main__':
    p=multiprocessing.Process(target=foo)
    print('Process before execution :',p,p.is_alive())#is_alive追踪进程的状态
    p.start()
    print('Process is running:',p,p.is_alive())
    p.terminate()
    print("Process terminated:",p,p.is_alive())
    p.join()
    print('Process joined:',p,p.is_alive())
    print('Process exit code:',p.exitcode)#结果是-15，表明进程被中断